package com.zchat.api.modules.chat;

import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManagerListener;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.packet.Message;

import android.content.Context;

import com.zchat.api.log.Logger;
import com.zchat.api.modules.Module;
import com.zchat.api.util.ZChatSetting;

/**
 * 单人聊天管理
 * @author Oliverzhu
 *	2012/6/26
 */
public class SingleChatMessageManager extends Module implements ChatManagerListener {
	private Context context;

	@Override
	public void chatCreated(Chat chat, boolean createdLocally) {
		if(ZChatSetting.DEBUG)
		{
			Logger.debug("SingleChatMessageManager"+"-chatCreated");
		}
		chat.addMessageListener(new MessageListener() {
			public void processMessage(Chat newchat, Message message) {
				// 若是聊天窗口已存在，将消息转往目前窗口
				// 若是窗口不存在，开新的窗口并注册
				System.out
						.println("XmppMessageManager"+message.getFrom() + ":" + message.getBody());

			}
		});
	}
	
	public void setContext(Context context)
	{
		this.context = context;
	}

}
